package cn.iocoder.yudao.module.digital.service.cardchannel.model.common;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum CdkOrderStatusEnum {
    SUBMIT_INIT("SUBMIT_INIT", "提交订单-初始化"),
    SUBMIT_SUCCESS("SUBMIT_SUCCESS", "提交订单-成功"),
    SUBMIT_FAILURE("SUBMIT_FAILURE", "提交订单-失败"),
    SUBMIT_EXCEPTION("SUBMIT_EXCEPTION", "提交订单-异常"),

    QUERY_FAILURE("QUERY_FAILURE", "查询订单-失败"),
    QUERY_EXCEPTION("QUERY_EXCEPTION", "查询订单-异常"),

    CARD_PROCESSING("CARD_PROCESSING", "创建卡密-处理中"),
    CARD_FAILURE("CARD_FAILURE", "创建卡密-失败"),
    CARD_PARTIAL_SUCCESS("CARD_PARTIAL_SUCCESS", "创建卡密-部分成功"),
    CARD_SUCCESS("CARD_SUCCESS", "创建卡密-成功");

    private final String value;
    private final String desc;

    public String getValue() {
        return value;
    }

    public boolean isNotCreateCardCompletedStatus() {
        return !isCreateCardCompletedStatus();
    }

    public boolean isCreateCardCompletedStatus() {
        if (this == CdkOrderStatusEnum.CARD_SUCCESS
                || this == CdkOrderStatusEnum.CARD_PARTIAL_SUCCESS
                || this == CdkOrderStatusEnum.CARD_FAILURE) {
            return true;
        }
        return false;
    }

    public static CdkOrderStatusEnum fromValue(String value) {
        for (CdkOrderStatusEnum type : values()) {
            if (type.value.equals(value)) {
                return type;
            }
        }
        throw new IllegalArgumentException("枚举类型 CdkOrderStatusEnum 不支持的值：" + value);
    }

}
